package com.dashu.device.service;


import com.dashu.base.utils.CopyUtil;
import com.dashu.device.dto.attendance.AttendanceTimeDTO;
import com.dashu.device.model.AttendanceTime;
import com.dashu.device.model.QAttendanceTime;
import com.querydsl.core.BooleanBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Slf4j
@Service
public class AttendanceTimeService extends DataService {
    @Autowired
    private AttendanceDateService attendanceDateService;

    public AttendanceTimeDTO findAttendancekGroup(long timeId) {
        QAttendanceTime qAttendanceTime = QAttendanceTime.attendanceTime;
        BooleanBuilder booleanBuilder = new BooleanBuilder();
        booleanBuilder.and(qAttendanceTime.id.eq(timeId));
        AttendanceTime attendanceTime =
                queryFactory
                        .select(qAttendanceTime)
                        .from(qAttendanceTime)
                        .where(booleanBuilder.getValue())
                        .fetchOne();
        AttendanceTimeDTO attendanceTimeDTO = CopyUtil.copyEnty(attendanceTime, AttendanceTimeDTO.class);
        return attendanceTimeDTO;

    }

}
